package de.dnb.basics.filtering;

import de.dnb.basics.applicationComponents.RangeCheckUtils;

/**
 * Filterkriterium UND.
 * 
 * @author Michael Inden
 * 
 * Copyright 2011 by Michael Inden 
 */
public class And<T> implements IPredicate<T> {

	private final IPredicate<T>[] predicates;

	public And(final IPredicate<T>... predicates) {
		for (IPredicate<T> predicate : predicates) {
			RangeCheckUtils
				.assertReferenceParamNotNull("filter", predicate);
		}
		this.predicates = predicates;

	}

	@Override
	public final boolean accept(final T object) {
		for (IPredicate<T> predicate : predicates) {
			if (!predicate.accept(object))
				return false;
		}
		return true;
	}
}
